package chapter02;

import java.io.FileNotFoundException;
import java.io.PrintStream;

/**
 * Created by a on 2017/6/8.
 */
public class Test021 {
    public static void main(String[] args) {
        try {
        PrintStream out = System.out;
        PrintStream ps = new PrintStream("./log.txt");
        System.setOut(ps);
        int age = 18;
        System.out.println("年龄变量成功定义,初始化值为18");
        String sex = "女";
        System.out.println("性别变量成功定义,初始化值为女");
        String info = "这是个"+sex+"的孩子,应该有"+age+"岁了.";
        System.out.println("整合两个变量为info字符串变量,其结果是:"+info);
        System.setOut(out);
        System.out.println("程序运行完毕,请检查日志文件");
        }catch (FileNotFoundException e){
            System.out.println("我错了");
            e.printStackTrace();
        }

    }
}
